package com.zhkj.txg.module.find.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zhkj.lib.utils.SpanUtil
import com.zhkj.txg.R
import com.zhkj.txg.module.find.entity.AssociateProductEntity
import com.zhkj.txg.utils.ImageUtils

class AssociateProductAdapter :
    BaseMultiItemQuickAdapter<AssociateProductEntity, BaseViewHolder>(), LoadMoreModule {
    init {
        addItemType(AssociateProductEntity.TYPE_NONE, R.layout.item_product_none)
        addItemType(AssociateProductEntity.TYPE_PRODUCT, R.layout.item_product_associate)
    }

    override fun convert(helper: BaseViewHolder, item: AssociateProductEntity) {
        if (item.itemType == AssociateProductEntity.TYPE_PRODUCT) {
            val imageView = helper.setText(R.id.tvAssociateProductTitle, item.goodsName)
                .setText(R.id.tvAssociateProductPrice, SpanUtil.setMoneySymbol(item.goodsPrice))
                .setVisible(R.id.tvAssociateProductEarn, false)
                .getView<ImageView>(R.id.ivAssociateProduct)
            ImageUtils.loadRoundCornerImage(context, imageView, item.image)
        }
    }
}